﻿namespace AlohaAlgorithm.Tests
{
    using System;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Moq;

    using Shared;

    [TestClass]
    public class SlottedSlottedAlohaAlgorithmFixture : AlohaAlgorithmFixture
    {
        [TestMethod]
        public new void ShouldReturnTheTimeElapsedToSend()
        {
            const int NumberOfClients = 1;
            const int DeltaTime = 100;

            var successDistribution = new Mock<IDistribution>();
            successDistribution.Setup(x => x.NextDouble(1, NumberOfClients + 1))
                .Returns(1);

            SlottedAlohaAlgorithm algorithm = (SlottedAlohaAlgorithm)this.CreateAlgorithm(successDistribution.Object);
            var elapsedTime = algorithm.Send(new Frame(1), NumberOfClients, DeltaTime, It.IsAny<Action<int, double>>());

            Assert.AreEqual(elapsedTime, DeltaTime + algorithm.WaitTime);
        }

        protected override IAlgorithm CreateAlgorithm(IDistribution distribution)
        {
            return new SlottedAlohaAlgorithm(distribution);
        }
    }
}
